package com.hxq.wap.dao;


import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import com.hxq.wap.entity.UserEntity;

public interface UserDao extends JpaRepository<UserEntity, String>, JpaSpecificationExecutor<UserEntity>{
	public UserEntity findByUserNameAndPassword(String userName,String password);
	public Long countByUserName(String userName);
	@Transactional
	@Modifying(clearAutomatically = true)
	@Query("update UserEntity user  set user.password =:password where user.userName =:userName") 
	void updatePassword(@Param("userName")String userName,@Param("password")String password);
	
	@Modifying
	@Transactional
	@Query("delete from UserEntity user where user.id = ?1")
	int deleteByEgId(int id);
	
}
